﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TeachingAffairsManagementSystem.WebControl;

namespace TeachingAffairsManagementSystem.UserControl.RightContent.Teacher
{
    public partial class MyLesson : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void BtnInsert_Click(object sender, EventArgs e)
        {
            int t_id = Convert.ToInt32(Session["id"]);
            string name = TBName.Text;
            string info = TBInfo.Text;
            if (name == "")
            {
                Alert.Show("课程名称不能为空", AlertBox.Level.Danger, true);
                return;
            }

            DSMyLesson.InsertParameters["teacher_t_id"].DefaultValue = t_id.ToString();
            DSMyLesson.InsertParameters["name"].DefaultValue = name;
            DSMyLesson.InsertParameters["info"].DefaultValue = info;
            DSMyLesson.Insert();
            Alert.Show("成功新建课程", AlertBox.Level.Success, true);
        }

        protected void GVLesson_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            switch (e.CommandName)
            {
                case "LookUpMyStudent":
                    int commandIndex = Convert.ToInt32(e.CommandArgument);
                    string l_id = GVMyLesson.Rows[commandIndex].Cells[0].Text;
                    Utils.OpenWindow($"Main.aspx?p=ms&l_id={l_id}");
                    break;
            }
        }
    }
}